<?php
	class Model_vote extends CI_Model{
		protected $_table = "tbl_votes_track";
		protected $_ship = "tbl_sheep";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function count_all(){
			$this->db->join("tbl_sheep","tbl_sheep.sheep_id = tbl_votes_track.sheep_id");
			return $this->db->count_all_results($this->_table);
		}
		public function listcate($off,$start){
			$this->db->join("tbl_sheep","tbl_sheep.sheep_id = tbl_votes_track.sheep_id");
			$this->db->order_by("votet_id","DESC");
			return $this->db->get($this->_table)->result_array();
		}
		public function update_status($data,$id){
			$this->db->where("votet_id",$id);
			$this->db->update($this->_table,$data);
		}
		public function getdata($id){
			$this->db->where("votet_id",$id);
			return $this->db->get($this->_table)->row_array();
		}
		public function getship($id){
			$this->db->where("sheep_id",$id);
			return $this->db->get($this->_ship)->row_array();
		}
		public function del($id){
			$this->db->where("votet_id",$id);
			$this->db->delete($this->_table);
		}
	}